home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 05 - 1989 / 05.03 Mar 89 / calc source / EntrData.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-12-09  |  1.8 KB  |  63 lines  |  [TEXT/KAHL]

  1. #include <ListMgr.h>
  2. #include <DialogMgr.h>
  3. #include <MemoryMgr.h>
  4. #include <QuickDraw.h>
  5.  
  6. #include "MacCalc.h"
  7. #include "SheetHndlg.h"
  8. #include "CalcData.h"
  9. #include "Parser.h"
  10.  
  11. #define ENTER_BUTTON  1
  12. #define CANCEL_BUTTON 2
  13. #define DATA_ITEM     4
  14.  
  15. void EnterData( cell, sheet_record_hdl )
  16. Cell cell ;
  17. SHEET_WIN_HDL sheet_record_hdl ;
  18. {
  19.     DialogPtr new_dialog ;
  20.     int item_hit ;
  21.     Handle hdl ;
  22.     Rect box ;
  23.     int type ;
  24.     int had_data = FALSE ;
  25.      
  26.     if( ( cell.v ) != 0 && ( cell.h != 0 ) ) {
  27.      
  28.         HLock( (Handle)sheet_record_hdl ) ;
  29.         new_dialog = GetNewDialog( ENTER_DATA_DIALOG, NULL, (WindowPtr)-1L ) ;
  30.         
  31.         /* Outline button */
  32.         SetPort( new_dialog ) ;
  33.         GetDItem( new_dialog, ENTER_BUTTON, &type, &hdl, &box ) ;
  34.         PenNormal( ) ;
  35.         PenSize( 3,3 ) ;
  36.         InsetRect( &box, -4,-4 ) ;
  37.         FrameRoundRect( &box, 16,16 ) ;
  38.  
  39.         GetDItem( new_dialog, DATA_ITEM, &type, &hdl, &box ) ;
  40.           
  41.         if( (**sheet_record_hdl).sheet_data[cell.v-1][cell.h-1].formula[0] != 0 ) {
  42.             SetIText( hdl, (**sheet_record_hdl).sheet_data[cell.v-1][cell.h-1].formula ) ;
  43.             SelIText( new_dialog, DATA_ITEM, 0, 255 ) ;
  44.             had_data = TRUE ;
  45.         }
  46.           
  47.         do{
  48.             ModalDialog( NULL, &item_hit ) ;
  49.         }while( item_hit == DATA_ITEM ) ;
  50.           
  51.         if( item_hit != CANCEL_BUTTON ) {
  52.             GetIText( hdl, &(**sheet_record_hdl).sheet_data[cell.v-1][cell.h-1].formula ) ;
  53.             SetType( &(**sheet_record_hdl).sheet_data[cell.v-1][cell.h-1], had_data ) ;
  54.             calc_hdl = sheet_record_hdl ;
  55.             calc_data = TRUE ;
  56.         }
  57.         CloseDialog( new_dialog ) ;
  58.         HUnlock( (Handle)sheet_record_hdl ) ;
  59.     }else{
  60.         SysBeep( 1 ) ;
  61.     }
  62.     return ;
  63. }